/// @tags: DP
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

int const N = 2e5 + 5, mod = 998244353;

int n, x, y;
set<int> s[N];

pair<int, int> dfs(int l, int r) {
  if (r == l + 1) return make_pair(1, 1);
  int x = *s[r].upper_bound(l);
  pair<int, int> A = dfs(l, x), B = dfs(x, r);
  int one =
      ((LL)A.first * B.second + (LL)A.second * B.first + (LL)A.first * B.first) % mod;
  int two = ((LL)A.first * B.second + (LL)A.second * B.first) % mod;
  return make_pair(one, two);
}

inline int main() {
  cin >> n;
  for (int i = 1; i <= n - 3; ++i) {
    cin >> x >> y;
    if (x < y)
      s[y].insert(x);
    else
      s[x].insert(y);
  }
  for (int i = 2; i <= n; ++i) s[i].insert(i - 1);
  cout << dfs(1, n).first;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("geometry.in", "r", stdin);
  freopen("geometry.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
